home *** CD-ROM | disk | FTP | other *** search
/ Die Ultimative Software-P…i Collection 1996 & 1997 / Die Ultimative Software-Pakete CD-ROM fur Atari Collection 1996 & 1997.iso / g / gnu_c / pmlsrc23.zoo / pmlsrc / ctan.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-19  |  2.1 KB  |  98 lines

  1. /************************************************************************
  2.  *                                    *
  3.  *                N O T I C E                *
  4.  *                                    *
  5.  *            Copyright Abandoned, 1987, Fred Fish        *
  6.  *                                    *
  7.  *    This previously copyrighted work has been placed into the    *
  8.  *    public domain by the author (Fred Fish) and may be freely used    *
  9.  *    for any purpose, private or commercial.  I would appreciate    *
  10.  *    it, as a courtesy, if this notice is left in all copies and    *
  11.  *    derivative works.  Thank you, and enjoy...            *
  12.  *                                    *
  13.  *    The author makes no warranty of any kind with respect to this    *
  14.  *    product and explicitly disclaims any implied warranties of    *
  15.  *    merchantability or fitness for any particular purpose.        *
  16.  *                                    *
  17.  ************************************************************************
  18.  */
  19.  
  20.  
  21. /*
  22.  *  FUNCTION
  23.  *
  24.  *    ctan   complex double precision tangent
  25.  *
  26.  *  KEY WORDS
  27.  *
  28.  *    ctan
  29.  *    complex functions
  30.  *    machine independent functions
  31.  *    math libraries
  32.  *
  33.  *  DESCRIPTION
  34.  *
  35.  *    Computes double precision complex tangent of a double
  36.  *    precision complex argument.
  37.  *
  38.  *  USAGE
  39.  *
  40.  *    COMPLEX ctan (z)
  41.  *    COMPLEX z;
  42.  *
  43.  *  PROGRAMMER
  44.  *
  45.  *    Fred Fish
  46.  *    Tempe, Az 85281
  47.  *    (602) 966-8871
  48.  *
  49.  *  INTERNALS
  50.  *
  51.  *    Computes complex tangent of z = x + j y from:
  52.  *
  53.  *        1.    Compute ccos(z)
  54.  *
  55.  *        2.    If ccos(z) = 0 + j0 then the
  56.  *            result is MAX_POS_DBLF + j0
  57.  *
  58.  *        3.    Else ctan(z) = csin(z) / ccos(z)
  59.  *
  60.  */
  61.  
  62. #if defined (__M68881__) && !defined (_M68881)
  63. /*# define _M68881*/
  64. #endif
  65.  
  66. #include <stdio.h>
  67. #include <math.h>
  68. #include "pml.h"
  69.  
  70. COMPLEX ctan (z)
  71. COMPLEX z;
  72. {
  73.     COMPLEX ccosz,csinz;
  74.     double  denom;
  75.  
  76.     ccosz = ccos (z);
  77.     csinz = csin (z);
  78.  
  79.     if (ccosz.real == 0.0 && ccosz.imag == 0.0) {
  80. #ifdef    ERROR_CHECK
  81.     fputs (stderr, " ctan: SINGULARITY\n");
  82.     errno = ERANGE;        /* should be EDOM if csinz.real or csinz.imag == 0    */
  83.  
  84.     if( csinz.real >= 0.0)    z.real = HUGE_VAL;    
  85.                     /* still wrong, == 0 should yield NAN */
  86.     else            z.real = -HUGE_VAL;    
  87.     if( csinz.imag >= 0.0)     z.imag = HUGE_VAL;
  88.                     /* still wrong, == 0 should yield NAN */
  89.     else            z.imag = -HUGE_VAL;    
  90. #else    ERROR_CHECK
  91.     z = cdiv(csinz,ccosz);
  92. #endif    ERROR_CHECK
  93.     } else {
  94.     z = cdiv(csinz,ccosz);
  95.     }
  96.     return (z);
  97. }
  98.